-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add optional strict unmarshalling for LoadFunctionConfig and SimpleProcessor #5926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add optional strict unmarshalling for LoadFunctionConfig and SimpleProcessor #5926
Conversation
Welcome @lorenzofelletti! |
Hi @lorenzofelletti. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…pleProcessor - Introduced a new boolean field `Strict` in the SimpleProcessor struct to control strict unmarshalling behavior when loading function configurations. - Updated the LoadFunctionConfig function to accept the `strict` parameter, allowing it to use strict unmarshalling. - Modified SimpleProcessor to be able to control the behaviour - Modified VersionedAPIProcessor, and TemplateProcessor to pass strict false. - Added unit tests for LoadFunctionConfig to cover scenarios for strict mode, including successful loads and failure cases for unknown fields.
5403069
to
fcf54f5
Compare
This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there, @lorenzofelletti!
Thanks for your contribution!
Could you please explain a little bit further the motivation for this change, such as a specific error mode or scenario?
/test all |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lorenzofelletti The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @stormqueen1990! I'm developing a KRM function in which I'd like the configuration not to allow extra fields, e.g. I want to avoid users inadvertently doing X instead of Y: # X
spec:
fieldA:
fieldB: true
fieldC: 4
# Y
spec:
fieldA:
fieldC: 4
fieldB: true If that happens, It'd be much faster if an incorrect configuration just fails because of serialisation error. To achieve this behaviour, one currently has to filter the ResourceList items, find the config manifest, serialise it, deserialise it again with the strict option, fail if the deserialisation errors. By adding this option as a function configuration parameter, it is much easier for the function's developers to achieve this behaviour out-of-the-box. I've set the feature to default to |
Motivation
When using
SimpleProcessor
one may want to have strict unmarshalling for the function config and throw an error if any unknown field is supplied in the configuration.The current behaviour does not allow this flexibility. Adding strict option to
LoadFunctionConfig
and adding aStrict
field toSimpleProcessor
allows to programmatically change the unmarshalling behaviour, while keeping the current behaviour as the default.Changes
Strict
in the SimpleProcessor struct to control strict unmarshalling behavior when loading function configurations.strict
parameter, allowing it to use strict unmarshalling.